﻿


jQuery().ready(function(){
	
	var oDiv = document.getElementById("page_num");
	var oSpan = oDiv.getElementsByTagName("span");
	var oUl = document.getElementById("page_ul");
	var oLi = oUl.getElementsByTagName("li");
	oSpan[0].onclick = function(){
		oUl.style.display = "block";
		return false;	
	}
	
	oUl.onmouseleave=function(){
		oUl.style.display = "none";
		return false;	
	}
	
});


function expertPage(page){
    jQuery("#selectpage").html("第"+page+"页");
	jQuery("#page_ul").attr("style","display:none");
    
	$.ajax({
		  type: 'GET',
		  url: 'expagin',
		  data: 'page='+page,
		  success: showResponse,
		
		});
}

function showResponse(data)
{
	var expertList=eval(data);
	var curpage=1;
	var maxpage=1;
	var html="";
	

	jQuery("#exlist").find("dl").remove();
	jQuery("#exlist").find("div[class='more']").remove();

	for(var i=0;i<expertList.length;i++){
		var ex=expertList[i];
		if(i==0){
			maxpage=ex.maxpage;
			curpage=ex.curpage;
		
		}else{
		  html=html+"<dl><dt><img src=\"images/expert/e_"+ex.id+".jpg\" /></dt> <dd><h3>名称："+ex.name+"<br />职称："+ex.post+"</h3>" +
		  		"<p>"+ex.description+"</p></dd></dl><div class=\"more\">[<a href=\"expert?id="+ex.id+"\">了解更多</a>]</div>";
		  
		}
	}
	
	
	jQuery("#exlist").prepend(html);
	
    if(curpage==1){
    	
    	jQuery("#upage").html("<a style=\"color:#ccc;\" href=\"javascript:void(0)\">上一页 </a>");
    	var page=parseInt(curpage)+1;
    	if(curpage==maxpage){
		  jQuery("#nextpage").html("<a style=\"color:#ccc;\" href=\"javascript:void(0)\">下一页 </a>");
    	}else{
    	  jQuery("#nextpage").html("<a href=\"javascript:expertPage("+page+")\">下一页 </a>");
    	}
    }
    else if(curpage>1 && curpage<maxpage){
		var uppagin=parseInt(curpage)-1;
		jQuery("#upage").html("<a href=\"javascript:expertPage("+uppagin+")\">上一页 </a>");
		
		var nextpagin=parseInt(curpage)+1;
		jQuery("#nextpage").html("<a href=\"javascript:expertPage("+nextpagin+")\">下一页 </a>");
	}else if(curpage==maxpage){
		var page=parseInt(curpage)-1;
		jQuery("#upage").html("<a href=\"javascript:expertPage("+page+")\">上一页 </a>");
		jQuery("#nextpage").html("<a style=\"color:#ccc;\" href=\"javascript:void(0)\">下一页 </a>");
	}
		

}

function courseOrder(cid){
	var uid=jQuery("#uid").val();

	if(uid==-1 || uid==""){
		ytwx.dialog("提示", "id:r_login_error", "435px", "", "l_in");	
	}else{
		window.location.href ="order?cid="+cid;
	}

		
}


function checkOrdre(cid){
	var uid=jQuery("#uid").val();

	if(uid==-1 || uid==""){
		ytwx.dialog("提示", "id:r_login_error", "435px", "", "l_in");	
	}else{
		window.location.href ="lb?c="+cid;
	}
}
